package com.atguigu.service.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.atguigu.dao.ReportDao;
import com.atguigu.service.ReportService;
import com.atguigu.util.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;

@Service(interfaceClass = ReportService.class)
@Transactional
public class ReportServiceImpl implements ReportService {

    @Autowired
    ReportDao reportDao;

    @Override
    public List<Integer> getMemberReport(List<String> list) {

        List<Integer> list1 = new ArrayList<>();
        for (String s : list) {
            String lastDayOfMonth = DateUtils.getLastDayOfMonth(s);
            String mouth = s + "-" + lastDayOfMonth;
            Integer i = reportDao.getMemberReport(mouth);
            list1.add(i);
        }
        return list1;
    }

    @Override
    public List<Map<String, Object>> getSetmealReport() {
        return reportDao.getSetmealReport();
    }

    @Override
    public Integer todayNewMember(String format) {
        return reportDao.todayNewMember(format);
    }

    @Override
    public Integer totalMember() {
        return reportDao.totalMember();
    }

    @Override
    public Integer thisWeekNewMember(String format) {

        Date thisWeekMonday = DateUtils.getThisWeekMonday();
        return reportDao.thisWeekNewMember(thisWeekMonday);
    }

    @Override
    public Integer thisMonthNewMember() {
        Date firstDay4ThisMonth = DateUtils.getFirstDay4ThisMonth();
        return reportDao.thisMonthNewMember(firstDay4ThisMonth);
    }

    @Override
    public Integer todayOrderNumber(String format) {
        return reportDao.todayOrderNumber(format);
    }

    @Override
    public Integer todayVisitsNumber(String format) {
        return reportDao.todayVisitsNumber(format);
    }

    @Override
    public Integer thisWeekOrderNumber() {
        Date thisWeekMonday = DateUtils.getThisWeekMonday();
        return reportDao.thisWeekOrderNumber(thisWeekMonday);
    }

    @Override
    public Integer thisWeekVisitsNumber() {
        Date thisWeekMonday = DateUtils.getThisWeekMonday();
        return reportDao.thisWeekVisitsNumber(thisWeekMonday);
    }

    @Override
    public Integer thisMonthOrderNumber() {
        Date firstDay4ThisMonth = DateUtils.getFirstDay4ThisMonth();
        return reportDao.thisMonthOrderNumber(firstDay4ThisMonth);
    }

    @Override
    public Integer thisMonthVisitsNumber() {
        Date firstDay4ThisMonth = DateUtils.getFirstDay4ThisMonth();
        return reportDao.thisMonthVisitsNumber(firstDay4ThisMonth);
    }

    @Override
    public List<Map<String, Object>> hotSetmeal() {
        return reportDao.hotSetmeal();
    }
}
